﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MODULE_KETOAN
{
    public class cls_ketoan
    {
        public System.Windows.Forms.Form parent;
        private ketoanDataContext ccontext = new ketoanDataContext(getconnectstring());
        public static ketoanDataContext getcontext()
        {
            return new ketoanDataContext(getconnectstring());
        }
        public void ShowForm(string formname)
        {
            // Object frm;

            switch (formname)
            {
                case "frm_rpt_bangkethanhtoan":

                    frm_rpt_bangkethanhtoan frm1 = new frm_rpt_bangkethanhtoan();
                    frm1.MdiParent = parent;
                    frm1.Show();
                    break;
                case "frm_rpt_bangkethumua":
                    frm_rpt_bangkethumua frm2 = new frm_rpt_bangkethumua();
                    frm2.MdiParent = parent;
                    frm2.Show();
                    
                    break;
                case "frm_rpt_tonghopthumua":
                    frm_rpt_tonghopthumua frm3 = new frm_rpt_tonghopthumua();
                    frm3.MdiParent = parent;
                    frm3.Show();
                    
                    break;
                case "frm_rpt_tonghopvachitietcongno":
                    frm_rpt_tonghopvachitietcongno frm4 = new frm_rpt_tonghopvachitietcongno();
                    frm4.MdiParent = parent;
                    frm4.Show();
                    
                    break;
                case "frm_thanhtoantienhang":
                    frm_thanhtoantienhang frm5 = new frm_thanhtoantienhang();
                    frm5.MdiParent = parent;
                    frm5.Show();
                    
                    break;
                case "frm_banggiathumua":
                    frm_banggiathumua frm6 = new frm_banggiathumua();
                    frm6.MdiParent = parent;
                    frm6.Show();
                    break;

            }
        }
        public static string getconnectstring()
        {
            string kq = "";
            XmlDocument MyDoc = new XmlDocument();

            MyDoc.Load("extension\\extension.xml");
            XmlNode root = (XmlNode)MyDoc.DocumentElement;

            for (int i = 0; i < root.ChildNodes.Count; i++)
            {
                XmlNode element = (XmlNode)root.ChildNodes[i];
                if (element.Name == "connection")
                {
                    kq = element.Attributes["connectionString"].Value.ToString();
                }
            }
            return kq;

        }

        
        
    }
}
